home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kparts / statusbarextension.h < prev   
Encoding:
C/C++ Source or Header  |  2005-10-10  |  4.4 KB  |  127 lines

  1. /* This file is part of the KDE project
  2.    Copyright (C) 2003 Daniel Molkentin <molkentin@kde.org>
  3.    Copyright (C) 2003 David Faure <faure@kde.org>
  4.  
  5.    This library is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Library General Public
  7.    License as published by the Free Software Foundation; either
  8.    version 2 of the License, or (at your option) any later version.
  9.  
  10.    This library is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    Library General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU Library General Public License
  16.    along with this library; see the file COPYING.LIB.  If not, write to
  17.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.    Boston, MA 02110-1301, USA.
  19.  */
  20.  
  21. #ifndef KPARTS_STATUSBAREXTENSION_H
  22. #define KPARTS_STATUSBAREXTENSION_H
  23.  
  24. #include <qwidget.h>
  25. #include <qvaluelist.h>
  26.  
  27. #include <kdelibs_export.h>
  28.  
  29. class KStatusBar;
  30. class KMainWindow;
  31. class QEvent;
  32.  
  33. namespace KParts
  34. {
  35.  
  36.   class ReadOnlyPart;
  37.  
  38.   // Defined in impl
  39.   class StatusBarItem;
  40.  
  41.  
  42.   /**
  43.    * @short An extension for KParts that allows more sophisticated statusbar handling
  44.    *
  45.    * Every part can use this class to customize the statusbar as long as it is active.
  46.    * Add items via addStatusBarItem() and remove an item with removeStatusBarItem().
  47.    *
  48.    * IMPORTANT: do NOT add any items immediately after constructing the extension.
  49.    * Give the application time to set the statusbar in the extension if necessary.
  50.    *
  51.    * @since 3.2
  52.    */
  53.   class KPARTS_EXPORT StatusBarExtension : public QObject
  54.   {
  55.     Q_OBJECT
  56.  
  57.     public:
  58.       StatusBarExtension( KParts::ReadOnlyPart *parent, const char *name=0L );
  59.       ~StatusBarExtension();
  60.  
  61.       /**
  62.        * This adds a widget to the statusbar for this part.
  63.        * If you use this method instead of using statusBar() directly,
  64.        * this extension will take care of removing the items when the parts GUI
  65.        * is deactivated and will re-add them when it is reactivated.
  66.        * The parameters are the same as QStatusBar::addWidget().
  67.        *
  68.        * Note that you can't use KStatusBar methods (inserting text items by id)
  69.        * but you can create a KStatusBarLabel with a dummy id instead, and use
  70.        * it directly in order to get the same look and feel.
  71.        *
  72.        * @param widget the widget to add
  73.        * @param stretch the stretch factor. 0 for a minimum size.
  74.        * @param permanent passed to QStatusBar::addWidget as the "permanent" bool.
  75.        * Note that the item isn't really permanent though, it goes away when
  76.        * the part is unactivated. This simply controls where temporary messages
  77.        * hide the @p widget, and whether it's added to the left or to the right side.
  78.        *
  79.        * IMPORTANT: do NOT add any items immediately after constructing the extension.
  80.        * Give the application time to set the statusbar in the extension if necessary.
  81.        */
  82.       void addStatusBarItem( QWidget * widget, int stretch, bool permanent );
  83.  
  84.       /**
  85.        * Remove a @p widget from the statusbar for this part.
  86.        */
  87.       void removeStatusBarItem( QWidget * widget );
  88.  
  89.       /**
  90.        * @return the statusbar of the KMainWindow in which this part is currently embedded.
  91.        * WARNING: this could return 0L
  92.        */
  93.       KStatusBar* statusBar() const;
  94.  
  95.       /**
  96.        * This allows the hosting application to set a particular KStatusBar
  97.        * for this part. If it doesn't do this, the statusbar used will be
  98.        * the one of the KMainWindow in which the part is embedded.
  99.        * Konqueror uses this to assign a view-statusbar to the part.
  100.        * The part should never call this method!
  101.        */
  102.       void setStatusBar( KStatusBar* status );
  103.  
  104.       /**
  105.        * Queries @p obj for a child object which inherits from this
  106.        * BrowserExtension class. Convenience method.
  107.        */
  108.       static StatusBarExtension *childObject( QObject *obj );
  109.  
  110.       /** @internal */
  111.       virtual bool eventFilter( QObject *watched, QEvent* ev );
  112.  
  113.     private:
  114.  
  115.      QValueList<StatusBarItem> m_statusBarItems; // Our statusbar items
  116.      mutable KStatusBar* m_statusBar;
  117.  
  118.      // for future extensions
  119.      class StatusBarExtensionPrivate;
  120.      StatusBarExtensionPrivate *d;
  121.   };
  122.  
  123. }
  124. #endif // KPARTS_STATUSBAREXTENSION_H
  125.  
  126. // vim: ts=2 sw=2 et
  127.